<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="com.example.utils.DButil" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.Connection" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2025/1/6
  Time: 2:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Guanzhu</title>
</head>
<body>
<%
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
    Connection con = null;

    try {
//        System.out.println("number:" + request.getParameter("number"));
        con = DButil.getConnection();
        ps = con.prepareStatement("INSERT INTO friend (USERID, FRIENDID, GUANZHU) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE GUANZHU = VALUES(GUANZHU)");
        ps.setString(1, request.getParameter("userid"));
        ps.setString(2, request.getParameter("guanzhuid"));
        ps.setString(3, request.getParameter("number"));
        ps.executeUpdate();

        ps1 = con.prepareStatement("INSERT INTO liaotian(USERID1,USERID2,CONTENT) VALUES(?,?,'Hello')");
        ps1.setString(1, request.getParameter("userid"));
        ps1.setString(2, request.getParameter("guanzhuid"));
        ps1.executeUpdate();


    } catch (SQLException e) {
        throw new RuntimeException(e);
    }finally {
        DButil.closeResources(con,ps,ps1);
    }
%>
</body>
</html>
